import matplotlib.pyplot as plt
from playLA.Matrix import Matrix
import math

if __name__ == "__main__":
    points = [[0,0],[0,5],[3,5],[3,4],[1,4],
              [1,3],[2,3],[2,2],[1,2],[1,0]]

    x = [pt[0] for pt in points]
    y = [pt[1] for pt in points]

    plt.figure(figsize=(5,5))
    plt.xlim(-10,10)
    plt.ylim(-10,10)

    plt.plot(x,y)

    m1 = Matrix(points)

    #将m1中[x,y]变成列向量
    m2 = m1.T()

    # 斜体
    # p = Matrix([[1,0.5],[0,1]])

    # 旋转
    angle = math.pi/3

    # p = Matrix([
    #     [ math.cos(angle),math.sin(angle)],
    #     [-math.sin(angle),math.cos(angle)]
    #     ])

    # 矩阵表示空间
    # 列向量表示（x,y）新坐标系在当前坐标系下的坐标
    p = Matrix([[0,-1],
               [1, 0]])

    m3 = p.dot(m2)

    x2 = m3.row_vector(0)[:]
    y2 = m3.row_vector(1)[:]

    plt.plot(x2,y2)

    plt.show()

    pass